package com.key.controller.admin.setting;

import com.key.common.R;
import com.key.common.vo.AssetFieldVO;
import com.key.service.AssetCodeService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;



@Controller
@RequestMapping("asset_code")
@Api(value = "资产编码模板",tags = "资产编码模板设置接口API")
public class AssetCodeController {
    @Autowired
    private AssetCodeService assetCodeService;

    @RequestMapping(value = "/findAllAssetField",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "显示左右两边框中数据",notes = "查询字段左表和字段右表",httpMethod = "get", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R findAllAssetField(){
        //System.out.println(assetCodeService.getCode());
        return assetCodeService.findAllAssetField();
    }

    @RequestMapping(value = "/commit",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "提交表中数据",notes = "提交模板数据",httpMethod = "post", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R commit(@RequestBody @ApiParam(name = "assetFieldVO",value = "资产编码模板",required = true)AssetFieldVO assetFieldVO){

        return assetCodeService.updateAssetCode(assetFieldVO);
    }
}
